<?php


namespace App\Transformers\Store;


use App\Models\LiveAnchor;
use App\Models\StoreServiceFeedback;
use App\Models\User;
use App\Transformers\MerchantRegistersTransformer;
use App\Transformers\User\UserTransformer;
use League\Fractal\TransformerAbstract;

class StoreServiceFeedbackTransformer extends TransformerAbstract
{
    protected $availableIncludes = ['user','mer'];

    public function transform(StoreServiceFeedback $data)
    {
        return [
            'id' => $data->id,
            'user_id' => $data->user_id ?? "",
            'name' => $data->name ?? "",
            'content' => $data->content ?? "",
            'make' => $data->make ?? "",
            'phone' => $data->phone ?? "",
            'status' => $data->status ?? 0,
            'created_at' => $data->created_at ? $data->created_at->format("Y-m-d H:i:s") : '',
            'updated_at' => $data->updated_at ? $data->updated_at->format("Y-m-d H:i:s") : '',
        ];
    }

    /**
     * 用户留言所关联的用户的数据
     */
        public function  includeuser(StoreServiceFeedback $storeServiceFeedback){
            return $this->item($storeServiceFeedback->user,new UserTransformer());
    }

    /**
     * 用户留言所关联的用户的数据
     */
        public function includemer(StoreServiceFeedback $storeServiceFeedback){
            return $this->item($storeServiceFeedback->mer, new MerchantRegistersTransformer());
        }

}
